<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class AdminTranslateRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method) {
            case 'GET':
                return $this->getRule();
            case 'POST':
            default:
                return [];
        }
    }

    protected function getRule()
    {
        return [
            'title' => 'required|string',
            'original_url' => 'required|string|url',
            'body_original' => 'required|string',
        ];
    }

    public function attributes()
    {
        return [
            'title' => '翻译标题',
            'original_url' => '翻译原文url',
            'body_original' => '翻译原文',
        ];
    }
}
